package com.example.wallpaperapp.ui.activity;

import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.wallpaperapp.R;
import com.example.wallpaperapp.adapter.HomeChoicAdapter;
import com.example.wallpaperapp.base.BaseActivity;
import com.example.wallpaperapp.bean.FindPreviewBean;
import com.example.wallpaperapp.bean.HomeImageRecyclerViewBean;
import com.example.wallpaperapp.bean.HomeChoicBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 精选页面
 */
public class ChoicenessActivity extends BaseActivity {
    private RecyclerView near_recyclerview;
    private List<HomeImageRecyclerViewBean> list = new ArrayList<>();
    private List<HomeChoicBean> list2 = new ArrayList<>();
    private ImageView back;

    @Override
    protected int initLayout() {
        return R.layout.activity_choiceness;
    }

    @Override
    protected void initView() {
        back=(ImageView)findViewById(R.id.ad_back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        list.add(new HomeImageRecyclerViewBean(R.drawable.image0));
        list.add(new HomeImageRecyclerViewBean(R.drawable.image2));
        list.add(new HomeImageRecyclerViewBean(R.drawable.image1));
        list2.add(new HomeChoicBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1603697069543&di=52ea9deab5e252f7003b54c691d159e7&imgtype=0&src=http%3A%2F%2Fa3.att.hudong.com%2F64%2F52%2F01300000407527124482522224765.jpg", 2));
        list2.add(new HomeChoicBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1603697069543&di=52ea9deab5e252f7003b54c691d159e7&imgtype=0&src=http%3A%2F%2Fa3.att.hudong.com%2F64%2F52%2F01300000407527124482522224765.jpg", 1));
        list2.add(new HomeChoicBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1603697069543&di=52ea9deab5e252f7003b54c691d159e7&imgtype=0&src=http%3A%2F%2Fa3.att.hudong.com%2F64%2F52%2F01300000407527124482522224765.jpg", 3));
        near_recyclerview = findViewById(R.id.choiceness_recycler);
        StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
        layoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
        near_recyclerview.setLayoutManager(layoutManager);
        HomeChoicAdapter adapter = new HomeChoicAdapter(this, list2);
        adapter.setOnItemClickListener(new HomeChoicAdapter.MyOnItemClickListener() {
            @Override
            public void myOnItemClickListener(int position, View view) {
                Toast.makeText(ChoicenessActivity.this, "点击了第" + position + "条", Toast.LENGTH_SHORT).show();
                ArrayList<String> list = new ArrayList<>();
                list.add(list2.get(position).getUrl());
                list.add(list2.get(position).getUrl());
                list.add(list2.get(position).getUrl());
                FindPreviewActivity.startFindPreviewActivity(ChoicenessActivity.this, new FindPreviewBean(list));
            }
        });
        near_recyclerview.setAdapter(adapter);
    }

    @Override
    protected void initData() {
    }
}
